package leetcode.code1901;

import leetcode.IDebug;

public class Solution implements IDebug {

	int[] d = new int[] { 0, -1, 0, 1, -1, 0, 1, 0 };
	int m;
	int n;

	public int[] findPeakGrid(int[][] mat) {
		m = mat.length;
		n = mat[0].length;
		return this.findPeakGrid(mat, 0, 0);
	}

	private int[] findPeakGrid(int[][] mat, int x, int y) {
		for (int i = 0; i < 8; i += 2) {
			int nextx = x + d[i], nexty = y + d[i + 1];
			if (nextx >= 0 && nextx < m && nexty >= 0 && nexty < n && mat[x][y] < mat[nextx][nexty]) {
				return this.findPeakGrid(mat, nextx, nexty);
			}
		}
		return new int[] { x, y };
	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
